package com.xc.hotelmgr.webapi.modules.op.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xc.hotelmgr.webapi.common.utils.PageUtils;
import com.xc.hotelmgr.webapi.common.utils.Query;

import com.xc.hotelmgr.webapi.modules.op.dao.RoomPriceDao;
import com.xc.hotelmgr.webapi.modules.op.entity.RoomPriceEntity;
import com.xc.hotelmgr.webapi.modules.op.service.RoomPriceService;


@Service("roomPriceService")
public class RoomPriceServiceImpl extends ServiceImpl<RoomPriceDao, RoomPriceEntity> implements RoomPriceService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String dtId = (String) params.get("dtId");
        String hotelId = (String) params.get("hotelId");
        String roomId = (String) params.get("roomId");
        IPage<RoomPriceEntity> page = this.page(
                new Query<RoomPriceEntity>().getPage(params),
                new QueryWrapper<RoomPriceEntity>().eq(StringUtils.isNotBlank(dtId), "dt_id", dtId)
                        .eq(StringUtils.isNotBlank(hotelId), "hotel_id", hotelId)
                        .eq(StringUtils.isNotBlank(roomId), "room_id", roomId)
        );
        return new PageUtils(page);
    }

}